<?php
class AddComponentForm extends Zend_Form
{
	public function init()
	{
		$fronController = Zend_Controller_Front::getInstance();
		$request = $fronController->getRequest();
		$projectId = $request->getParam('projectId');
		
		$Project = new Project();
		$projectName = $Project->getProjectName($projectId);
		
		$project = $this->createElement('hidden','project');
		$project->setLabel('* Project:')
				->setRequired(true)
				->setValue($projectId)
				->setDescription($projectName);
		
		$cname = $this->createElement('text','cname');
		$cname->setLabel('* Name:')
			->setRequired(true);
			
		$description = $this->createElement('textarea','description');
		$description->setLabel('Description')
					->setAttrib('rows',5)
					->setAttrib('cols',40)
					->setAttrib('style','width:90%');
		
					
		$add = $this->createElement('submit','add');
		$add->setLabel('Add')
				->setDecorators(array(
							'viewHelper',
								'Errors',
								array('Description', array('tag'=>'', 'escape'=>false)),
								array(array('data'=>'HtmlTag'),
									array('tag'=>'td', 'valign'=>'top', 'style'=> 'background-color:#ffffff;text-align:center','openOnly'=>true,'colspan'=>2,'align'=>'center')),
								//array('Label', array('tag'=>'td')),
								array(array('row'=>'HtmlTag'), array('tag'=>'tr','openOnly'=>true))
				));
				
		$cancel = $this->createElement('button','cancel');
		$cancel->setLabel('Cancel')
				->setDecorators(array(
							'viewHelper',
								'Errors',
								array('Description', array('tag'=>'', 'escape'=>false)),
								array(array('data'=>'HtmlTag'),
									array('tag'=>'td', 'valign'=>'top', 'style'=> 'background-color:#ffffff;','closeOnly'=>true)),
								//array('Label', array('tag'=>'td')),
								array(array('row'=>'HtmlTag'), array('tag'=>'tr','closeOnly'=>true))
				));
					
		$this->addElements(array(
					$project,
					$cname,
					$description,
					$add,
					$cancel
		));
		
		$this->setElementDecorators(array(
								'viewHelper',
								'Errors',
								array('Description', array('tag'=>'', 'escape'=>false)),
								array(array('data'=>'HtmlTag'),
									array('tag'=>'td', 'valign'=>'top', 'style'=> 'background-color:#ffffff;text-align:left')),
								array('Label', array('tag'=>'td')),
								array(array('row'=>'HtmlTag'), array('tag'=>'tr'))),
								array('project','cname', 'description')
								);
								
		$this->addDecorators(array(
				'FormElements',
				array('HtmlTag', array('tag' => 'table','width'=>'100%','cellspacing'=>'0','border'=>'0','class'=>'pform')),
				'Form'
		));
	}
}